package com.fjut.kms.service;

import com.fjut.kms.dao.UserLicenseReqDao;
import com.fjut.kms.dao.UserLicenseReqJDBCImpl;
import com.fjut.kms.domain.UserLicenseReq;
import com.fjut.kms.exception.KMSException;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Empathy on 2017/7/30.
 */
public class UserLicenseReqServiceImpl implements UserLicenseReqService{
    public void add(UserLicenseReq ulr){
        UserLicenseReqDao ulrd=new UserLicenseReqJDBCImpl();
        ulrd.addUserLicenseReq(ulr);
    }

    public List<Object> get(String userName){
        if (userName.equals("")) throw new KMSException("用户名为空");
        UserLicenseReqDao ulrd=new UserLicenseReqJDBCImpl();
        List<UserLicenseReq> ulrList=new ArrayList<UserLicenseReq>();
        ulrList=ulrd.getUserLicenseReq(userName);
        if (ulrList==null) throw new KMSException("查询结果为空");
        List<Object> list=new ArrayList<Object>();
        for (int i=0;i<ulrList.size();i++){
            list.add(ulrList.get(i));
        }
        return list.size()>0?list:null;
    }
}
